//
//  UserViewModel.m
//  DataStatistics
//
//  Created by 123456 on 16/6/15.
//  Copyright © 2016年 YTYangK. All rights reserved.
//

#import "UserViewModel.h"
#import "UserModel.h"
@implementation UserViewModel

    

#pragma mark - 个人中心
+ (void)requestWithUrlForUser:(id)user andParam:(NSDictionary *)param success:(void (^)(UserModel *model))success failure:(void (^)(NSString *err))failure {

    
    [NetRequestClss requestWithUrl:@"account/account.asp" requestWithParameters:param method:NetMethodPOST returnSuccess:^(id objs, int status, NSString *mag) {
        if (objs != nil) {
            [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
            [[UtilToolsClss getUtilTools] removeDoLoading];
            
            UserModel *list  = [UserModel mj_objectWithKeyValues:objs[@"body"]];
            
            success(list); return;
        }
        failure(@"暂无数据");
    } returnError:^(NSString *err) {
        failure(err); //返回是因为需要列表拉下来
    }];
    
}


#pragma mark - 退出登录
+ (void)requestWithUrlForlogoutOnline:(id)obj andParam:(NSDictionary *)param success:(void (^)(id model))success failure:(void (^)(NSString *err))failure {
    [[UtilToolsClss getUtilTools] addDoLoading];
    [NetRequestClss requestWithUrl:@"login/logout.asp" requestWithParameters:param method:NetMethodPOST returnSuccess:^(id objs, int status, NSString *mag) {
        [[UtilToolsClss getUtilTools] removeDoLoading];
        NSLog(@"退出登录返回信息----->%@",objs);
        
        
        NSString *  resultStr = [[objs objectForKey:@"body"] objectForKey:@"result"];
        if ([resultStr intValue]  == 1) {
            success(mag);
        }else {
            failure(@"退出失败了"); //什么
        }
    } returnError:^(NSString *err) {
        [[UtilToolsClss getUtilTools] removeDoLoading];
        failure(err);
    }];
}

@end
